<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="98px">
      <el-form-item label="项目名称" prop="projectName">
        <el-input
          v-model="queryParams.projectName"
          placeholder="请输入项目名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="检查类型" prop="checkType">
        <DictRadio v-model="queryParams.checkType" :radioData="checkTypeOptions" :showAll="'all'"
                   size="small" @change="handleQuery"></DictRadio>
      </el-form-item>

      <el-form-item label="检查方式" prop="checkMethod">
        <DictRadio v-model="queryParams.checkMethod" :radioData="checkMethodOptions" :showAll="'all'"
                   size="small" @change="handleQuery"></DictRadio>
      </el-form-item>

<!--      <el-form-item label="所属管辖大队" prop="deptId">-->
<!--        <el-input-->
<!--          v-model="queryParams.deptId"-->
<!--          placeholder="请输入所属管辖大队"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->

      <el-form-item label="检查人" prop="checkByName">
        <el-input
          v-model="queryParams.checkByName"
          placeholder="请输入检查人"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="检查时间" prop="checkTime">
        <el-date-picker clearable
                        v-model="queryParams.checkTime"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择检查时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="管辖大队" prop="deptId">
        <treeselect v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择所属管辖大队" style="width: 200px;" clearable @keyup.enter.native="handleQuery"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['check:checkRecord:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['check:checkRecord:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['check:checkRecord:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['check:checkRecord:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="checkRecordList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="施工检查记录id" align="center" prop="checkRecordId" width="120"/>
      <el-table-column label="施工报备单号" align="center" prop="reportNum" />
      <el-table-column label="项目名称" align="center" prop="projectName" width="180" :show-overflow-tooltip='true'/>
      <el-table-column label="检查类型" align="center" prop="checkType" :formatter="this.formatterCheckType" />
<!--      <el-table-column label="检查内容" align="center" prop="checkContent" width="120">-->
<!--        <template slot-scope='scope'>-->
<!--          <el-popover-->
<!--            placement="top-start"-->
<!--            width="120"-->
<!--            trigger="hover">-->
<!--            <span>{{scope.row.checkContent}}</span>-->
<!--            <span slot="reference">{{scope.row.checkContent.substr(1,5) + '...'}}</span>-->
<!--          </el-popover>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="检查方式" align="center" prop="checkMethod" :formatter="this.formatterCheckMethod" />
      <el-table-column label="检查时间" align="center" prop="createTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="现场联系人" align="center" prop="head" />
      <el-table-column label="联系电话" align="center" prop="telePhone" />
      <el-table-column label="问题描述" align="center" prop="problemDesc" :show-overflow-tooltip='true'/>
      <el-table-column label="道路名称" align="center" prop="roadName" :show-overflow-tooltip='true' />
      <el-table-column label="所属管辖大队" align="center" prop="deptName" />
      <el-table-column label="检查人" align="center" prop="checkByName" />
      <el-table-column label="同行检查人" align="center" prop="peerReviewerName" />

      <el-table-column label="是否通知施工方" align="center" key="isNoticeCons" width="120">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.isNoticeCons"
            :active-value = '1'
            :inactive-value = '0'
            disabled
          ></el-switch>
        </template>
      </el-table-column>


      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['check:checkRecord:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['check:checkRecord:remove']"
          >删除</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row,scope.index)"
          >详情</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改施工检查记录对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="今日施工" prop="reportBusinessId">
              <el-select v-model="form.reportBusinessId" filterable placeholder="请选施今日施工" style="width: 100%"  @change="handleChange">
<!--                <el-option-->
<!--                  v-for="item in todayCheckTaskListOption"-->
<!--                  :key="item.businessId"-->
<!--                  :label="'流水单号=' + item.reportNum + ',施工类型=' + item.consTypeDesc + ',施工单位=' + item.construnctionUnit + ',联系人=' + item.head + ',联系电话=' + item.telePhone"-->
<!--                  :value="item.businessId">-->
<!--                </el-option>-->
                <el-option
                  v-for="item in todayCheckTaskListOption"
                  :key="item.businessId"
                  :label="item.reportNum"
                  :value="item.businessId">
                  <span style="float: left">{{ item.reportNum }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{'项目名称:' + item.projectName + ',施工类型:' + item.consTypeDesc + '，施工单位:' + item.construnctionUnit + '，联系人:' + item.head + '，联系电话:' + item.telePhone}}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row >
          <el-col :span="8">
            <el-form-item label="施工报备单号" prop="reportInfoId">
              <el-select v-model="form.reportInfoId" filterable placeholder="请选施工报备单号" style="width: 100%" :disabled="this.disabledSelectReportInfo" @change="handleReportChange">
                <el-option
                  v-for="item in reportInfoOption"
                  :key="item.reportInfoId"
                  :label="item.reportNum"
                  :value="item.reportInfoId">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检查类型" prop="checkType">
              <el-select v-model="form.checkType" placeholder="请选择检查类型" :disabled="this.disabledSelectReportInfo">
                <el-option
                  v-for="item in checkTypeOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="检查内容" prop="checkContent">
<!--              <el-input v-model="form.checkContent" type="textarea" placeholder="请输入内容" />-->
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form ref="checkItemForm" :model="checkItemForm">
              <!--检查项表格-->
              <el-table ref="table" v-loading="loading" :data="checkItemList" v-if="this.checkItemList.length >0">
                <el-table-column type="selection" width="155" align="center" prop="isCheck" />
                <el-table-column label="检查项id" align="left" prop="checkItemId" width="200" />
                <el-table-column label="检查项名称" align="left" prop="checkItemName" width="300" />
                <el-table-column label="检查结果" align="center" prop="checkResult" >
                  <template slot-scope="scope">
                    <div class="choose">
                      <el-radio v-model="scope.row.checkResult" :label="0"
                      >是</el-radio
                      >
                      <el-radio v-model="scope.row.checkResult" :label="1"
                      >否</el-radio
                      >
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-col>
        </el-row>

        <el-row style="margin-top: 10px;">
          <el-col :span="8">
            <el-form-item label="检查方式" prop="checkMethod">
              <el-select v-model="form.checkMethod" placeholder="请选择检查方式">
                <el-option
                  v-for="item in checkMethodOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="现场联系人" prop="head">
              <el-input v-model="form.head" placeholder="请输入现场联系人" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系电话" prop="telePhone">
              <el-input v-model="form.telePhone" placeholder="请输入联系电话" />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="问题描述" prop="problemDesc">
              <el-input v-model="form.problemDesc" type="textarea" placeholder="请输入问题描述" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="16">
            <el-form-item label="问题照片/视频" prop="problemFileId">
            <file-upload  @input="getFileList" :fileLocationName="'problemFile'" :value="this.problemFileData" :fileType="['png','jpg','jpeg','video','mp4']" :limit="5" :fileSize="50"/>
          </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通知施工方" prop="isNoticeCons">
              <el-switch
                v-model="form.isNoticeCons"
                :active-value= 1
                :inactive-value= 0>
              </el-switch>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="所属管辖大队" prop="deptName">
              <el-input v-model="form.deptName" placeholder="请输入所属管辖大队" :disabled="true" />
<!--              <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属大队" @select="this.getDetpUser"/>-->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检查人" prop="checkByName">
              <el-input v-model="form.checkByName" placeholder="请输入检查人" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="同行检查人" prop="peerReviewer">
              <el-select v-model="form.peerReviewer" placeholder="同行检查人" style="width: 220px">
                <el-option
                  v-for="user in userOptions"
                  :key="user.userId"
                  :label="user.nickName"
                  :value="user.userId"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 施工检查记录详情对话框 -->
    <el-dialog :title="title" :visible.sync="viewOpen" width="1000px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-row >
          <el-col :span="8">
            <el-form-item label="施工报备单号：">{{ form.reportNum }}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检查类型：">{{this.formatterCheckType(null,null,form.checkType) }}</el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="检查内容："></el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form ref="checkItemForm" :model="checkItemForm">
              <!--检查项表格-->
              <el-table ref="table" v-loading="loading" :data="checkItemList" v-if="this.checkItemList.length >0">
                <el-table-column type="selection" width="155" align="center" prop="isCheck" />
                <el-table-column label="检查项id" align="left" prop="checkItemId" width="200" />
                <el-table-column label="检查项名称" align="left" prop="checkItemName" width="300" />
                <el-table-column label="检查结果" align="center" prop="checkResult" >
                  <template slot-scope="scope">
                    <div class="choose">
                      <el-radio v-model="scope.row.checkResult" :label="0" disabled
                      >是</el-radio
                      >
                      <el-radio v-model="scope.row.checkResult" :label="1" disabled
                      >否</el-radio
                      >
                    </div>
                  </template>
                </el-table-column>
              </el-table>
            </el-form>
          </el-col>
        </el-row>

        <el-row style="margin-top: 10px;">
          <el-col :span="8">
            <el-form-item label="检查方式：">{{ this.formatterCheckMethod(null,null,form.checkMethod) }}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="现场联系人：">{{ form.head }}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="联系电话：">{{ form.telePhone }}</el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="24">
            <el-form-item label="问题描述：">{{ form.problemDesc }}</el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="16">
            <el-form-item label="检查照片/视频" prop="problemFileId">
              <image-preview :value="this.problemFileData"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="通知施工方" prop="isNoticeCons">
              <el-switch
                v-model="form.isNoticeCons"
                :active-value= 1
                :inactive-value= 0
                disabled>
              </el-switch>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
<!--          <el-col :span="8">
            <el-form-item label="经纬度：">{{ form.longitude + ',' + form.latitude}}</el-form-item>
          </el-col>-->
          <el-col :span="24">
            <el-form-item label="道路名称：">{{ form.roadName }}</el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="所属管辖大队：">{{ form.deptName }}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="检查人：">{{ form.checkByName }}</el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="同行检查人：">{{ form.peerReviewerName }}</el-form-item>
          </el-col>
        </el-row>

      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="viewOpen = false">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listCheckRecord, getCheckRecord, delCheckRecord, addCheckRecord, updateCheckRecord,selectTodayCheckTaskList } from "@/api/check/checkRecord";
import {selectListCheckItem } from "@/api/check/checkItem";
import { deptUserTreeSelect ,deptUserListSelect} from "@/api/system/user";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { selectListreportInfo} from "@/api/check/reportInfo";
export default {
  name: "CheckRecord",
  components: { Treeselect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 施工检查记录表格数据
      checkRecordList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      //  是否显示详情弹出层
      viewOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        reportInfoId: null,
        checkType: null,
        checkContent: null,
        checkMethod: null,
        roadName: null,
        deptId: null,
        checkBy: null,
      },
      // 表单参数
      form: {},

      // 检查内容表格数据
      checkItemList: [],
      //检查项表单
      checkItemForm: {
        checkItemId:'',
        checkItemName:'',
        isCheck:'',//是否需要检查
        checkResult:'',//检查结果 0 通过 1 不通过
      },
      //  组织部门
      deptOptions: undefined,
      //  部门人员
      userOptions: undefined,
      //  检查类型option
      checkTypeOptions :[{
        value: 0,
        label: '施工检查'
        },
        {
          value: 1,
          label: '撤场检查'
        }],

      //  检查方式option
      checkMethodOptions :[{
        value: 0,
        label: '线上检查'
      },
        {
          value: 1,
          label: '现场检查'
        },
        {
          value: 2,
          label: '网络+现场检查'
        }],

      //问题 附件
      problemFileData:[],

      //  报备信息option
      reportInfoOption:[],

      //   今日施工信息列表
      todayCheckTaskListOption:[],
      //  禁用施工报备下拉列表选项 默认开启
      disabledSelectReportInfo : false,

      // 表单校验
      rules: {
        reportInfoId: [
          { required: true, message: "施工报备id不能为空", trigger: "blur" }
        ],
        checkType: [
          { required: true, message: "检查类型不能为空", trigger: "blur" }
        ],
        checkMethod: [
          { required: true, message: "检查方式不能为空", trigger: "blur" }
        ],
        head: [
          { required: true, message: "现场联系人不能为空", trigger: "blur" }
        ],
        telePhone: [
          { required: true, message: "联系电话不能为空", trigger: "blur" }
        ],
        deptId: [
          { required: true, message: "所属管辖大队不能为空", trigger: "blur" }
        ],
        checkBy: [
          { required: true, message: "检查人不能为空", trigger: "blur" }
        ],
        peerReviewer: [
          { required: true, message: "同行检查人不能为空", trigger: "blur" }
        ],
        delFlag: [
          { required: true, message: "删除标志不能为空", trigger: "blur" }
        ],
        createBy: [
          { required: true, message: "创建者不能为空", trigger: "blur" }
        ],
        createTime: [
          { required: true, message: "创建时间不能为空", trigger: "blur" }
        ],
        updateBy: [
          { required: true, message: "更新者不能为空", trigger: "blur" }
        ],
        updateTime: [
          { required: true, message: "更新时间不能为空", trigger: "blur" }
        ]
      }
    };
  },
  created() {
    this.getList();
    this.getDeptTree();
  },
  methods: {
    /** 查询施工检查记录列表 */
    getList() {
      this.loading = true;
      listCheckRecord(this.queryParams).then(response => {
        this.checkRecordList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        checkRecordId: null,
        reportInfoId: null,
        checkType: null,
        checkContent: null,
        checkMethod: null,
        head: null,
        telePhone: null,
        problemDesc: null,
        problemFileId: null,
        longitude: null,
        latitude: null,
        roadName: null,
        deptId: null,
        checkBy: null,
        peerReviewer: null,
        isNoticeCons: null,
        delFlag: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null
      };
      this.resetForm("form");
      this.problemFileData = null;
      this.checkItemList = [];
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.checkRecordId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加施工检查记录";
      //默认设置检查人信息
      this.form.checkBy = this.$store.state.user.id;
      this.form.checkByName = this.$store.state.user.nickName;
      this.form.deptId = this.$store.state.user.deptId;
      this.getReportInfoList();
      this.getCheckItemList();
      //this.getDeptTree();
      //  报备下拉列表禁用
      this.disabledSelectReportInfo = false;
      this.getTodayCheckTaskList();
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const checkRecordId = row.checkRecordId || this.ids
      getCheckRecord(checkRecordId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改施工检查记录";
        //  默认设置检查人信息
        this.form.checkBy = this.$store.state.user.id;
        this.form.checkByName = this.$store.state.user.nickName;
        this.form.deptId = this.$store.state.user.deptId;
        //  检查项内容
        this.checkItemList = response.data.checkItemRecordList;
        //  问题图片/视频
        this.problemFileData = response.data.problemFile;
        this.getReportInfoList();
        //this.getDeptTree();
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          //施工检查项 以及检查结果
          this.form.checkItemRecord = JSON.stringify(this.checkItemList);
          if (this.form.checkRecordId != null) {
            updateCheckRecord(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addCheckRecord(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const checkRecordIds = row.checkRecordId || this.ids;
      this.$modal.confirm('是否确认删除施工检查记录编号为"' + checkRecordIds + '"的数据项？').then(function() {
        return delCheckRecord(checkRecordIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('check/checkRecord/export', {
        ...this.queryParams
      }, `checkRecord_${new Date().getTime()}.xlsx`)
    },

    /** 详细按钮操作 */
    handleView(row) {
      this.reset();
      const checkRecordId = row.checkRecordId || this.ids
      getCheckRecord(checkRecordId).then(response => {
        this.form = response.data;
        this.viewOpen = true;
        this.title = "查看施工检查记录";
        //  检查项内容
        this.checkItemList = response.data.checkItemRecordList;
        //  问题图片/视频
        this.problemFileData = response.data.problemFile;
      });

    },


    /** 获取检查内容列表 */
    getCheckItemList() {
      this.loading = true;
      selectListCheckItem({}).then(response => {
        this.checkItemList = response.data;
        this.loading = false;
      });
    },

    /** 查询部门下拉树结构 */
    getDeptTree() {
      deptUserTreeSelect().then(response => {
        this.deptOptions = response.data;
      });
    },

    /** 查询部门人员下拉列表结构 */
    getDetpUser(deptId) {
      deptUserListSelect({deptId:deptId}).then(response => {
        this.userOptions = response.data;
      });
    },

    /** 查询部门人员 */
    // async getDetpUser (val) {
    //   this.form.peerReviewer = '';
    //   this.userOptions = val.deptUsers;
    // },

    //获取附件列表
    getFileList(fileLocationName,fileIds,deleteFileId){
      this.form[fileLocationName] = fileIds;
    },

    // 格式化检查类型
    formatterCheckType(row, column, cellValue, index) {
      //  cellValue是当前单元格的值
      const obj = this.checkTypeOptions.find(item => item.value === cellValue)
      return obj ? obj.label : '未知'
    },

    // 格式化检查方式
    formatterCheckMethod(row, column, cellValue, index) {
      //  cellValue是当前单元格的值
      const obj = this.checkMethodOptions.find(item => item.value === cellValue)
      return obj ? obj.label : '未知'
    },

    /** 查询施工报备信息列表 */
    getReportInfoList() {
      this.loading = true;
      selectListreportInfo({}).then(response => {
        this.reportInfoOption = response.data;
        this.loading = false;
      });
    },

    /** 查询今日施工信息列表 */
    getTodayCheckTaskList(){
      this.loading = true;
      selectTodayCheckTaskList({}).then(response => {
        this.todayCheckTaskListOption = response.data;
        this.loading = false;
      });
    },

    /** 今日施工下拉列表 change事件 */
    handleChange(val){
      //选中的数据和options进行匹配
      var obj={}
      obj= this.todayCheckTaskListOption.find(function(i){
        return i.businessId ===val
      });
      //  报备下拉列表禁用
      this.disabledSelectReportInfo = true;
      this.form.reportInfoId = obj.reportInfoId;
      this.form.checkType = obj.checkType;
      this.form.tbName = obj.tbName;
      this.form.head = obj.head;
      this.form.telePhone = obj.telePhone;
      this.form.deptId = obj.deptId;
      this.form.deptName = obj.deptName;
      this.form.peerReviewer = '';
      this.getDetpUser(obj.deptId);
    },

    /** 施工报备单号 列表 change事件 */
    handleReportChange(val){
      //选中的数据和options进行匹配
      var obj={}
      obj= this.reportInfoOption.find(function(i){
        return i.reportInfoId ===val
      });
      this.form.reportInfoId = obj.reportInfoId;
      this.form.head = obj.head;
      this.form.telePhone = obj.telePhone;
      this.form.deptId = obj.deptId;
      this.form.deptName = obj.deptName;
      this.form.peerReviewer = '';
      this.getDetpUser(obj.deptId);
    }
  },

};
</script>
